package cc.iotkit.common.event;

import java.util.ArrayList;
import java.util.List;

public class EventSource {
    private List<CustomEventListener> listeners = new ArrayList<>();

    public void addCustomEventListener(CustomEventListener listener) {
        listeners.add(listener);
    }

    public void removeCustomEventListener(CustomEventListener listener) {
        listeners.remove(listener);
    }

    // 方法来触发事件
    public void fireEvent(String message) {
        CustomEvent event = new CustomEvent(this, message);
        for (CustomEventListener listener : listeners) {
            listener.onEventOccurred(event);
        }
    }
}
